// 新股 
<script lang="ts">
export default {
  name: "newShare",
};
</script>
<template>
  <div class="page-box h100 display-flex czbj">
    <div class="">
      <n-spin :show="show">
        <n-data-table
          size="small"
          :row-props="rowProps"
          :pagination="paginationReactive"
          :columns="columns"
          :data="tableData"
          :single-line="false"
          :max-height="700"
        />
      </n-spin>
    </div>
  </div>
</template>
<script lang='ts' setup>
import { h, ref, computed, reactive } from "vue";
import {
  dxget,
  transferTimeYMD,
  hf,
  transferTimeYMDSting,
} from "../../util/index";
import { getxg } from "../../util/dxjsonp";
import comp from "../../components/index";
let tableData = ref();
let show = ref(false);
const paginationReactive = reactive({
  page: 1,
  pageCount: 1,
  pageSize: 14,
  onChange: (page) => {
    paginationReactive.page = page;
  },
});
let columns = [
  {
    title: "股票号码",
    key: "APPLY_CODE",
    align: "center",
  },
  {
    title: "股票简称",
    key: "SECURITY_NAME",
    align: "center",
  },
  {
    title: "现价",
    key: "LATELY_PRICE",
    align: "center",
  },
  {
    title: "首日收盘价",
    key: "CLOSE_PRICE",
    align: "center",
  },
  {
    title: "现价与首日涨幅",
    key: "CLOSE_PRICE",
    align: "center",
    render(row) {
      let zf: any = (
        ((row.LATELY_PRICE - row.CLOSE_PRICE) / row.CLOSE_PRICE) *
        100
      ).toFixed(2);
      return h(comp.victory, { price: zf + "%", isQiz: zf < -20 });
    },
  },
  {
    title: "发行价格",
    key: "ISSUE_PRICE",
    align: "center",
  },
  {
    title: "每中一签获利(元)",
    key: "TOTAL_CHANGE",
    align: "center",
    render(row) {
      let num = "--";
      if (row.TOTAL_CHANGE) {
        num = row.TOTAL_CHANGE.toFixed(2);
      }
      return num;
    },
  },
  {
    title: "发行总数(万股)",
    key: "ISSUE_NUM",
    align: "center",
  },
  {
    title: "网上发行(万股)",
    key: "ONLINE_ISSUE_NUM",
    align: "center",
    render(row) {
      return row.ONLINE_ISSUE_NUM / 10000;
    },
  },

  {
    title: "发行市盈率",
    key: "AFTER_ISSUE_PE",
    align: "center",
  },
  {
    title: "中签率(%)",
    key: "ONLINE_ISSUE_LWR",
    align: "center",
    render(row) {
      return row.ONLINE_ISSUE_LWR.toFixed(2) + "%";
    },
  },
  {
    title: "上市日期",
    key: "LISTING_DATE",
    align: "center",
    render(row) {
      return transferTimeYMDSting(row.LISTING_DATE);
    },
  },
  {
    title: "操作",
    align: "center",
    key: "actions",
    render(row) {
      row.secCode = row.SECURITY_CODE;
      row.f3 = row.SECURITY_NAME;
      return h(comp.MoreOperations, {
        obj: [
          {
            label: "添加新股观察",
            key: "3",
          },
        ],
        rowData: row,
        onOperateFun: () => {
          show.value = false;
        },
        onShowLoad: () => {
          show.value = true;
        },
      });
    },
  },
];
const initData = async () => {
  let kjjhe: any = await getxg();
  //   LATELY_PRICE
  kjjhe = kjjhe.filter((row) => {
    let codes = row.APPLY_CODE.split("");
    return row.LATELY_PRICE && codes[0] != 7;
  });
  kjjhe.map((a, b) => {
    a.key = b;
  });
  tableData.value = kjjhe;
};
initData();
const rowProps = (row, aa) => {
  return {
    style: "cursor: pointer;",
    onClick: (idx) => {
      let numse = (
        ((row.LATELY_PRICE - row.CLOSE_PRICE) / row.CLOSE_PRICE) *
        100
      ).toFixed(2);
      hf("stockDetails", {
        code: row.APPLY_CODE,
        observetype: 3,
        ew: "现价与首日涨幅" + numse + "%",
      });
    },
  };
};
</script>
<style scoped>
</style>
